<template>
	<div>
	    <home-header :city="city"></home-header>
		<index-swiper :swiperList="swiper"></index-swiper>
		<index-nav :iconList="iconList"></index-nav>
		<index-recommend :recommendList="recommendList"></index-recommend>
		<index-like :likeList="likeList"></index-like>
		<index-weekend :weekendList="weekendList"></index-weekend>
	</div>
</template>

<script>
import HomeHeader from "./components/header.vue"
import IndexSwiper from "./components/index-swiper.vue"
import IndexNav from "./components/index-nav.vue"
import IndexRecommend from './components/index-recommend.vue'
import IndexLike from './components/index-like.vue'
import IndexWeekend from './components/index-weekend.vue'
import axios from "axios"
export default {
  name: 'Home',
  components:{   //引用局部组件
	  HomeHeader,
	  IndexSwiper,
	  IndexNav,
	  IndexRecommend,
	  IndexLike,
	  IndexWeekend
  },
  data(){
	  return{
		  city:"",
		  swiper:[],
		  iconList:[],
		  recommendList:[],
		  likeList:[],
		  weekendList:[]
	  }
	  
  },
  methods:{
	getIndexInfo(){
		axios.get('/api/index.json')
			.then(this.getHomeInfoSucc)
	},
	getHomeInfoSucc(res){
		console.log(res);
		res = res.data;
		if(res.ret && res.data){
			this.city = res.data.city;
			this.swiper = res.data.swiperList;
			this.iconList = res.data.iconList;
			this.recommendList = res.data.recommendList;
			this.likeList = res.data.likeList;
			this.weekendList = res.data.weekendList;
		}
		 
	}
  },
  mounted() {
  	this.getIndexInfo()
  }
}
</script>

<style>
</style>
